<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-row :gutter="1">
        <el-col :span="60">
          <el-form-item label="" prop="residentEnterprises">
            <el-input
              v-model="queryParams.residentEnterprises"
              placeholder="请输入要搜索的招聘企业"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>

        <el-col :span="60">
          <el-form-item label="" prop="stationName">
            <el-select v-model="queryParams.stationName" placeholder="请输入要搜索的岗位名称">
              <el-option label="测试" value="测试" @keyup="handleQuery"></el-option>
              <el-option label="运维" value="运维" @keyup="handleQuery"></el-option>
              <el-option label="前端开发" value="前端开发" @keyup="handleQuery"></el-option>
              <el-option label="后端开发" value="后端开发" @keyup="handleQuery"></el-option>
              <el-option label="人工智能" value="人工智能" @keyup="handleQuery"></el-option>
              <el-option label="大数据开发" value="大数据开发" @keyup="handleQuery"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="60">
          <el-form-item label="" prop="stationBackground">
            <el-select v-model="queryParams.stationBackground" placeholder="请输入要搜索的学历要求">
              <el-option label="初中及以下" value="初中及以下" @keyup="handleQuery"></el-option>
              <el-option label="中专/中技" value="中专/中技" @keyup="handleQuery"></el-option>
              <el-option label="高中" value="高中" @keyup="handleQuery"></el-option>
              <el-option label="大专" value="大专" @keyup="handleQuery"></el-option>
              <el-option label="本科" value="本科" @keyup="handleQuery"></el-option>
              <el-option label="硕士" value="硕士" @keyup="handleQuery"></el-option>
              <el-option label="博士" value="博士" @keyup="handleQuery"></el-option>
            </el-select>
          </el-form-item>
        </el-col>

        <el-col :span="60">
          <el-form-item label="" prop="stationWork">
            <el-select v-model="queryParams.stationWork" placeholder="请输入要搜索的工作经验">
              <el-option label="在校生" value="在校生" @keyup="handleQuery"></el-option>
              <el-option label="应届生" value="应届生" @keyup="handleQuery"></el-option>
              <el-option label="1年以内" value="1年以内" @keyup="handleQuery"></el-option>
              <el-option label="1-3年" value="1-3年" @keyup="handleQuery"></el-option>
              <el-option label="3-5年" value="3-5年" @keyup="handleQuery"></el-option>
              <el-option label="5-10年" value="5-10年" @keyup="handleQuery"></el-option>
              <el-option label="10年以上" value="10年以上" @keyup="handleQuery"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="0">
        <el-col :span="60">
          <el-form-item label="截止时间" prop="beginTime">
            <el-date-picker clearable
                            v-model="queryParams.beginTime"
                            type="date"
                            value-format="yyyy-MM-dd"
                            placeholder="请选择开始时间">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="60">
          <el-form-item prop="endTime">
            <el-date-picker clearable
                            v-model="queryParams.endTime"
                            type="date"
                            value-format="yyyy-MM-dd"
                            placeholder="请选择结束时间">
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:station:export']"
        >导出岗位
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>


    <el-table v-loading="loading" :data="stationList" @selection-change="handleSelectionChange">
      <!--    <el-table :data="stationList">-->
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column type="expand">
        <!--        <el-table-column prop="" label="序号" align="center" width="150">-->
        <!--          <template slot-scope="scope">-->
        <!--            {{ scope.$index + 1 + (queryParams.pageNum - 1) * queryParams.pageSize }}-->
        <!--          </template>-->
        <!--        </el-table-column>-->
        <el-table-column label="招聘企业" align="center" prop="residentEnterprises"/>
        <el-table-column label="岗位名称" align="center" prop="stationName"/>
        <el-table-column label="学历要求" align="center" prop="stationBackground"/>
        <el-table-column label="工作经验" align="center" prop="stationWork"/>
        <el-table-column label="招聘人数" align="center" prop="stationQuantity"/>
        <el-table-column label="用工时长(月)" align="center" prop="workData"/>
        <el-table-column label="截至时间" align="center" prop="stationEndtimt" width="180">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.stationEndtimt, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-share"
              @click="playVideo(scope.row.id)"
              v-hasPermi="['system:station:query']"
            >详情
            </el-button>

            <el-button
              size="mini"
              type="text"
              icon="el-icon-loading"
              @click="recovery(scope.row)"
              v-hasPermi="['system:station:recovery']"
            >恢复
            </el-button>
          </template>
        </el-table-column>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 历史详情对话框 -->
    <el-dialog :title="title" :visible.sync="videoVisible" width="80%" append-to-body>
      <el-tag>招聘中</el-tag>
      <el-descriptions title="公司信息">
        <el-descriptions-item label="招聘企业">{{ ItoStation.residentEnterprises }}</el-descriptions-item>
        <el-descriptions-item label="岗位名称">{{ ItoStation.stationName }}</el-descriptions-item>
        <el-descriptions-item label="学历要求">{{ ItoStation.stationBackground }}</el-descriptions-item>
        <el-descriptions-item label="工作经验">{{ ItoStation.stationWork }}</el-descriptions-item>
        <el-descriptions-item label="招聘人数">{{ ItoStation.stationQuantity }}</el-descriptions-item>

        <el-descriptions-item label="用工时长(月)">{{ ItoStation.workData }}</el-descriptions-item>
        <el-descriptions-item label="最低薪资">{{ ItoStation.minimumWage }}</el-descriptions-item>
        <el-descriptions-item label="最高薪资">{{ ItoStation.highestSalary }}</el-descriptions-item>
        <el-descriptions-item label="面议">{{ ItoStation.negotiable }}</el-descriptions-item>
        <el-descriptions-item label="招聘截止时间">{{ ItoStation.stationEndtimt }}</el-descriptions-item>
        <el-descriptions-item label="工作地点">{{ ItoStation.workPlace }}</el-descriptions-item>
        <hr>
      </el-descriptions>
      <el-descriptions>
        <el-descriptions-item label="岗位职责" span="18">
          {{ ItoStation.jobResponsibilities }}
        </el-descriptions-item>
        <hr>
        <el-descriptions-item label="岗位要求" span="18">
          {{ ItoStation.jobRequirements }}
        </el-descriptions-item>
        <hr>
      </el-descriptions>
    </el-dialog>
  </div>
</template>


<script>
import {taotaiStation, recovery, getStation} from "@/api/system/stations";

export default {
  name: "Station",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      stationList: [],

      // 岗位详情
      ItoStation: {
        id: null,
        residentEnterprises: null,
        stationName: null,
        stationBackground: null,
        stationWork: null,
        stationQuantity: null,
        workData: null,
        minimumWage: null,
        highestSalary: null,
        negotiable: null,
        stationEndtimt: null,
        beginTime: null,
        endTime: null,
        workPlace: null,
        jobResponsibilities: null,
        jobRequirements: null,
      },

      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      videoVisible: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        residentEnterprises: null,
        stationName: null,
        stationBackground: null,
        stationWork: null,
        stationQuantity: null,
        workData: null,
        minimumWage: null,
        highestSalary: null,
        negotiable: null,
        stationEndtimt: null,
        beginTime: null,
        endTime: null,
        workPlace: null,
        jobResponsibilities: null,
        jobRequirements: null,
        stationState: null,
        isDelete: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {}
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询【请填写功能名称】列表 */
    getList() {
      this.loading = true;
      taotaiStation(this.queryParams).then(response => {
        this.stationList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        residentEnterprises: null,
        stationName: null,
        stationBackground: null,
        stationWork: null,
        stationQuantity: null,
        workData: null,
        minimumWage: null,
        highestSalary: null,
        negotiable: null,
        stationEndtimt: null,
        beginTime: null,
        endTime: null,
        workPlace: null,
        jobResponsibilities: null,
        jobRequirements: null,
        createTime: null,
        updateTime: null,
        stationState: null,
        isDelete: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 恢复按钮操作 */
    recovery(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认恢复该岗位？').then(function () {
        return recovery(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("恢复成功");
      }).catch(() => {
      });
    },

    /** 导出按钮操作 */
    handleExport() {
      this.download('system/station/export', {
        ...this.queryParams
      }, `station_${new Date().getTime()}.xlsx`)
    },

    /** 详情按钮操作 */
    //点击按钮时,触发弹出效果
    playVideo(id) {
      getStation(id).then(response => {
        this.ItoStation = response.data;
        this.videoVisible = true
      });
    },

  }
};
</script>
